package com.mcc.app.energy.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.energy.domain.EnergyPowerStatistics;
import com.mcc.app.energy.service.IEnergyPowerStatisticsService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 能源电力耗电统计
 *
 * @author gxy
 * @date 2025-03-25
 */
@Api(tags = "能源电力耗电统计")
@RestController
@RequestMapping("/energy/power")
public class EnergyPowerStatisticsController extends BaseController {

    @Autowired
    private IEnergyPowerStatisticsService energyPowerStatisticsService;

    @ApiOperation("查询能源电力耗电统计列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('energy:power:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<EnergyPowerStatistics>> list(EnergyPowerStatistics energyPowerStatistics) {
        List<EnergyPowerStatistics> list = energyPowerStatisticsService.selectEnergyPowerStatisticsList(energyPowerStatistics);
        return getDataTable(list);
    }

    @ApiOperation("查询能源电力耗电统计列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('energy:power:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<EnergyPowerStatistics>> page(EnergyPowerStatistics energyPowerStatistics) {
        startPage();
        List<EnergyPowerStatistics> list = energyPowerStatisticsService.selectEnergyPowerStatisticsList(energyPowerStatistics);
        return getDataTable(list);
    }

    @ApiOperation("获取能源电力耗电统计详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('energy:power:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<EnergyPowerStatistics> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(energyPowerStatisticsService.selectEnergyPowerStatisticsById(id));
    }

    @ApiOperation("新增能源电力耗电统计")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('energy:power:add')")
    @Log(title = "能源电力耗电统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody EnergyPowerStatistics energyPowerStatistics) {
        return toAjax(energyPowerStatisticsService.insertEnergyPowerStatistics(energyPowerStatistics));
    }

    @ApiOperation("修改能源电力耗电统计")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('energy:power:edit')")
    @Log(title = "能源电力耗电统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody EnergyPowerStatistics energyPowerStatistics) {
        return toAjax(energyPowerStatisticsService.updateEnergyPowerStatistics(energyPowerStatistics));
    }

    @ApiOperation("删除能源电力耗电统计")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('energy:power:remove')")
    @Log(title = "能源电力耗电统计", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(energyPowerStatisticsService.deleteEnergyPowerStatisticsByIds(ids));
    }

    @ApiOperation("获取能源实时信息")
    @GetMapping("/getRealTimeInfo")
    public AjaxResult getRealTimeInfo() {
        return AjaxResult.success(energyPowerStatisticsService.getRealTimeInfo());
    }
    @ApiOperation("区域日月年电力统计")
    @ApiOperationSupport(order = 7)
    @GetMapping("/areaPowerChart")
    public AjaxResult areaPowerChart() {
        return AjaxResult.success(energyPowerStatisticsService.areaPowerChart());
    }

}
